package com.example.shop_2208.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.shop_2208.R
import com.example.shop_2208.entity.CommentEnity

class CommentAdapter:BaseMultiItemQuickAdapter<CommentEnity,BaseViewHolder>() {
    init {
        addItemType(0, R.layout.item_comment_one)
        addItemType(1,R.layout.item_comment_two)
        addItemType(2,R.layout.item_comment_three)
    }
    override fun convert(holder: BaseViewHolder, item: CommentEnity) {
        when (holder.itemViewType){
            0->{
                holder.setText(R.id.comment_name,item.username)
                holder.setText(R.id.comment_msg,item.msg)
                holder.setText(R.id.comment_time,item.createtime)
                Glide.with(context).load(item.icon).circleCrop().into(holder.getView(R.id.comment_icon))
            }
            2->{
                holder.setText(R.id.comment_name,item.username)
                holder.setText(R.id.comment_msg,item.msg)
                holder.setText(R.id.comment_time,item.createtime)
                holder.setText(R.id.comment_tousername,"${item.tousername}")
                Glide.with(context).load(item.icon).circleCrop().into(holder.getView(R.id.comment_icon))
            }
        }
    }
}